package com.baitiaojun.user.config;

import cn.hutool.core.thread.ThreadFactoryBuilder;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.concurrent.*;

/**
 * @类名 AsyncConfig
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2023/1/19 15:37
 * @版本 1.0
 */
@EnableAsync
@Configuration
public class AsyncConfig implements AsyncConfigurer {

    @Override
    public ThreadPoolExecutor getAsyncExecutor() {
        return new ThreadPoolExecutor (
            10,
            50,
            30000,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(1000),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy()
        );
    }
}
